home *** CD-ROM | disk | FTP | other *** search
/ Guidemac 2 / Guidemac 2.iso / Le Guide des Newton V3 / Logiciels Newton DP / NewtTurtle 1.0 / Newt ReadMe < prev    next >
Text File  |  1993-10-12  |  20KB  |  261 lines

  1. Newt ReadMe  10/12/93
  2. =====
  3. INTRODUCTION
  4. -----
  5.  
  6. About
  7. -----
  8.  
  9. "Newt":
  10. a turtle graphics programming environment,
  11. using Newton Script (instead of Logo)
  12.  
  13. Version 1.0 Copyright © S. Weyer 1993. All Rights Reserved.
  14.  
  15. This program is shareware.  It may be freely distributed via online services and bulletin boards if it is unmodified and includes the "Newt ReadMe" file.  It may not be commercially bundled or redistributed on CD-ROM, floppy disk or PCMCIA without my permission. After several days of trial use, please register your copy by sending $15 to the author.
  16.  
  17. Please read the rest of this file for help, examples, warnings and other information.
  18.  
  19. After several days of trial use, please register your copy by sending $15 to the author. In return, I will provide you with information about several additional features, a mini-tutorial on Newton Script, and first access to future updates.  Comments, suggestions also appreciated.
  20.  
  21. Stephen Weyer
  22. 17 Timber Knoll Drive
  23. Washington Crossing, PA 18977
  24. Internet: weyer@guest.apple.com
  25. America Online: SteveWeyer
  26. AppleLink: WEYER.S
  27.  
  28.  
  29. Newt vs. Turtle
  30. -----
  31. "Newton Turtle" and "NewtTurtle" seemed a bit too long, so I decided to shorten its name to "Newt", especially given its amphibious similarity to its Logo cousin.
  32.  
  33. So that Newt can appeal to many groups, it is gender "newtral" (perhaps even "newtered").  Most references herein will be to "Newt" or "it".
  34.  
  35.  
  36. Newton Script
  37. -----
  38. Newton Script is Newton's object-oriented implementation language (basic atomic objects are "newtrons"?)  This package allows you to write your own expressions/ scripts/methods and execute them directly on your Newton.  This assumes some familiarity with programming concepts and languages, such as Logo since commands names are similar though syntax is different.  Since I provide little description of Newton syntax or other functions, I strongly recommend that you stay reasonably close to the examples that I provide (or register to obtain a somewhat longer introduction, or you can buy the Newton ToolKit (NTK) and docs from APDA for $800).  
  39.  
  40. WARNING
  41. -----
  42. There's an obvious benefit vs. risk tradeoff here.  Exploring "mathematics microworlds" and doing problem solving by writing programs are "powerful ideas" (Seymour Papert).  At the same time, "a little learning [about programming] is a dangerous thing" (with apologies to Alexander Pope).  Though unlikely, you could, through careless experimentation, mess up the innards of your Newton by removing soups and zapping frames.
  43.  
  44. If you exercise some common sense, and stay within the commands and syntax I have suggested, I hope you have many hours of learning enjoyment.
  45.  
  46. At the same time, given the litigious nature of our society that yearns for risk without responsibility, I feel compelled to add the following warning  (repeated in other variations several places later): 
  47.  
  48. >>> WARNING: USE THIS PACKAGE AT YOUR OWN RISK! <<<
  49.  
  50. Hey, what's life without a little risk anyway?  Have fun!
  51.  
  52.  
  53. Shareware vs. Freeware
  54. -----
  55. Newt is my first shareware offering (earlier, I distributed a freeware game "PicoFermiBagels").  If you would like to encourage me to develop and release subsequent versions of Newt (e.g., with more documentation on current features and Newton Script, more source examples, and new features), then please show your support by sending in the shareware fee along with suggestions, bug reports and comments.  I had debated whether to "cripple" this version by not allowing you to save any or many methods.  However, I'd rather spend time my time figuring out how to enable rather than disable features.  Thanks.
  56.  
  57. Teaching Mathematics and Problem Solving
  58. -----
  59. Although I have written Logo curriculum for turtles, Legos, and other domains, this document provides only a few isolated examples.  I would encourage you to experiment, and to translate ideas and code from Logo materials and books, e.g., Abelson & diSessa.
  60.  
  61.  
  62. =====
  63. INTERFACE GUIDE
  64.  
  65. Main View
  66. ----
  67. • Erase: erases Newt's drawing area; leaves Newt in same position.
  68.  
  69. • <scrub in draw area>: also erases everything
  70.  
  71. • Home: teleports Newt to center, pointing up, with same pen setting
  72.  
  73. • <tap in draw area>: Newt will go to location of pen using current Pen setting, preserving heading. follow this with a scrub to give Newt a clean slate.
  74.  
  75. • Pen: pen thickness used in drawing (default: 1).  0 means Newt just moves (no line).
  76.   (saved as a Preference -- see Preferences).
  77.  
  78. • Newt?: if checked (default: true), displays Newt with its tip at current x,y, pointing in current direction, and "xor-ed" so not to interfere with current drawing. Turn off for faster drawing.  (saved as a Preference).
  79.  
  80. • Redraw: if checked (default: true), Newt maintains a display list. This means that subsequent drawing will be restored after various events that might erase or obscure your screen such as visiting another view (About or Define), dragging a keyboard, closing an error window, or after waking your Newton.  If you plan to erase and draw something different anyway, turning this off would save memory. (saved as a Preference).
  81.  
  82. • Times: the value in this field  (default: 0) can be used as a "times" variable in the Eval field.  The "Times" button uses this value for built-in iteration, e.g., if Times=4, Dist=40,Deg=90,  tapping on Times tells Newt to :go(40) then :turn(90) 4 times, i.e., making a square -- the Newton Script is written to the "Eval" field where it is executed (and you can edit it if you like).  Tap "Deg" to turn, then tap Times or Eval again.
  83.  
  84. • Dist: the value in this field  (default: 0) can be used as a "dist" variable in the Eval field.  The "Dist" button uses this value for distance, e.g., if Dist=20, tapping on Dist tells Newt to :go(20), moving 20 in the "forward" direction (i.e., along Newt's current heading).  This draws a line if Pen is a number.  A negative value just means go "backward".  To give you some idea of scale, Newt's drawing area is roughly 200x200.  Newt will clip at its drawing boundary.
  85.  
  86. • Deg: the value in this field  (default: 0) can be used as a "deg" variable in the Eval field.  The "Deg" button uses this value for degrees, e.g., if Deg=90, tapping on Deg tells Newt to :turn(90), turning right by 90 degrees.  A negative value just means turn "left".  Newt will "mod" your number to prevent dizziness.
  87.  
  88. [note: Extra spaces between digits for Times, Dist and Deg are ignored.  Decimal points may be included, though the times value is rounded]
  89.  
  90. • Eval: this field can contain a short program in Newton Script to be executed by tapping the "Eval" button.  Because of syntactic punctuation, it's probably best to double-tap to get the keyboard.  You can also use the names "times", "dist" and "deg", so if you change those values you can just Eval your expression again.  You can also edit this field as a method ("evalField") in the Define area where there's a larger area.   The keyboard may prompt you about adding new words or expressions to your dictionary -- tip: if you put spaces before and after parentheses, and after commas, the variable and method names offered will be more useful.  Eval button remains highlighted during execution.
  91.  
  92. I will not attempt to provide a complete description of Newton Script here -- I assume that either you're already familiar with it, have access to NTK documentation, or that you can figure out the syntax and sample commands from the examples and descriptions below.  Depending on demand, I can provide a mini-tutorial for more advanced manipulation of your Newt.
  93.  
  94. WARNING: IF YOU USE OTHER SYSTEM FRAMES, METHODS, AND FUNCTIONS, YOU DO SO AT YOUR OWN RISK.
  95.  
  96. Since NS is an object-oriented language, your programs or scripts are defined as "methods" on "newtView".  You tell Newt to do things by sending it a "message", e.g., "go".  You precede a message with a colon (:) and include zero or more parameters, i.e., values for variables.  For example, :go(50).  There are "slots" that contain values that you can access, such as "times", "dist", and "deg".  Here are some examples 
  97.  
  98. Examples:
  99.   :poly (4,100)  // draws a 4-sided polygon, where 100 = length of each side
  100.   :poly (times,dist)  // uses values in Times and Dist fields for poly
  101.   for i:=1 to times do begin :go (dist); :turn (deg); end  // when you click on "Times"
  102.   :squiral (18,100)  // draw 18 squares(each side 100), turning 360/18 after each
  103.   for sides:=3 to 10 do :poly (sides,dist)   // nested polys
  104.   :erase (); :poly (Random(3,15),Random(10,20)) // a random poly. sep mult stmts with ;
  105.   for i:=5 to 160 by 5 do begin :go(i); :turn(90); :beep(); end  // version of Newt icon
  106.  
  107. [Implementation note: these methods and slots are defined on the "newtView" frame.  Though normally you send a message to a specific frame, i.e., frame:message, it isn't necessary since these are sent implicitly to Newt.  Similarly, the slot values are accessible in context through inheritance, so you do not need to specify the frame where they reside, i.e., frame.slot]
  108.  
  109. If you spell something incorrectly, or use incorrect syntax or parameters, you will most likely get a Newton error box with a cryptic code.  A list of error codes near the end of this document may help a little, but basically you'll have to take a closer look at what you wrote, edit it and try again.
  110.  
  111. WARNING: I DO NOT PROVIDE A GENERAL INTERRUPT CAPABILITY (BEYOND THE MANUAL RESET BUTTON IN THE BACK).  I SUGGEST COMMON SENSE IN CHOOSING VALUES FOR ITERATION, RECURSION OR DISTANCE THAT ARE NOT "TOO LARGE".  I will generally provide some reasonable values to try.  There is a way to rewrite methods to be interruptible, but that's an advanced topic.
  112.  
  113. • Define: define your own methods.  see INTERFACE GUIDE: Define Screen later.
  114.  
  115. =====
  116.  
  117. Preferences
  118.  
  119. Newt saves your preferences for Pen, Newt? and Redraw in a "system soup" entry so that it can potentially persist across Newt sessions (sending the messages :pen, :visible, and :redraw does not save the values, nor reflected in the screen choices). If you do not Save any source methods within the Define Screen, then Newt will automatically remove this preference entry when you quit (and automatically recreate it with the last settings if you start again).  If you Save any existing or new methods, these also go into the preference entry.  However, the preference entry would then persist until 1) you Remove all methods (including poly and squiral) and then quit Newt; or 2) you use your favorite  soup cleaning utility to remove it manually (entry tag: "NewtTurtle" in the system soup).  I hope this provides a reasonable default for cleaning up after casual users (who write no methods) vs. preserving settings and source for others.
  120.  
  121. =====
  122.  
  123. METHOD DESCRIPTION
  124.  
  125. Basic Newt Methods
  126. -----
  127. • :beep()
  128. Newt beeps/squeaks
  129.  
  130. • :erase() 
  131. erase Newt's drawing area
  132.  
  133. • :go(distance)
  134. move Newt <distance> from current location, forward if positive <distance>, backward if negative <distance>.  if Pen is a number, draws a line. From center, Newt can go ~100 before reaching edge of drawing area.  Newt just clips the line and disappears if you command it to go outside . 
  135.  
  136. • :goPt(x,y)
  137. move Newt to a point relative to center (0,0).  50,50 would be 50 dots to the right and up (in Newt's coordinate system, y increases from bottom to top)
  138.  
  139. • :home() 
  140. move Newt to center, pointing up, ignoring but preserving current pen setting
  141.  
  142. • :pen(num)
  143. set size of pen.  typical values are 0,1,2,3.  [note: not saved as a Preference].
  144.  
  145. • :pendown() 
  146. same as :pen(1)
  147.  
  148. • :penup() 
  149. same as :pen(0)
  150.  
  151. • :turn(degrees)
  152. turn Newt <degrees> from current heading: positive<degrees> turns Newt to right, negative to left.
  153.  
  154. • :turnTo(degrees)
  155. turn Newt to an absolute heading, typically between 0 and 359.  0 is "straight up".
  156.  
  157.  
  158. Other/Advanced Newt Methods
  159. -----
  160. • :cCurve(...)
  161. a doubly-recursive, fractal-like method. some examples to try:
  162.     :cCurve(6,8,0)
  163.     :cCurve(8,4,0)
  164. try larger numbers at your own risk.  contact author for documentation and source
  165.  
  166. • :poly(sides,len)
  167. draw a polygon, e.g., :poly(6,50) is a hexagon.  :poly(times,dist) to use edit fields.
  168. source provided
  169.  
  170. • :redraw(flag)
  171. set redraw, i.e., maintain display list if flag=true.  [note: not saved as preference]
  172.  
  173. • :squiral(num,len)
  174. draw a square(poly(4,len)), then turn(360/num); do this num times. source provided
  175.  
  176. • :squiral2(num,len)
  177. an interruptible version of squiral.  e.g., :squiral2(30,80)).  Once it starts, Eval button unhilites, Stop Button appears.  you could change the Pen setting during execution, and/or hit the Stop button to stop Newt.  contact author for details about converting iterative and recursive methods to be interruptible.
  178.  
  179. • :visible(flag). 
  180. if flag is True, then show Newt.  if flag is nil,  hide Newt.  [not saved as preference].
  181.  
  182.  
  183. User-Defined Methods
  184. -----
  185.  
  186. After trying some of the earlier examples, if you're at all comfortable with the subset of Newton Script that I've shown so far, you should be ready to add and edit your own methods. At its simplest, a method could be used to create commands that you're more familiar with, e.g., to mimic your favorite dialect of Logo.  For example, "fd" and "bk" as synonyms for "go", or more complicated behavior like "spiral" or "house".   For this to work, your expression should begin with "func", followed by a list of any parameters in parentheses, followed by a single statement, which can be a "begin ... end" construct.  You supply any method arguments in the parens following "func", e.g., we might define "fd" as "func(distance) :go(distance)".  You edit these method definitions on the Define screen, described next.
  187.  
  188. =====
  189. USER INTERFACE
  190.  
  191. Define Screen
  192. -----
  193.  
  194. • Edit: the field to the right of the "Edit" button contains the name of the method you would like to edit.  You can write in a new name or select an existing method (for which there is source) by tapping the diamond.   Source for poly and squiral are provided.  You can also edit  "evalField", which gets saved back to the main screen (where you can include multiple expressions separated by semicolon (;), but don't precede with "func()" as for the real methods).  Method names begin with alphabetic characters (case is preserved but ignored) and can contain numbers.  The colon(:) is not part of the name for definition, it is just used when invoking it. Remember to tap the "Edit" button after selecting or entering a name.  New methods will provide a basic "func () begin end" template.  Attempting to Edit a "system" method (i.e., for which there is no source), an empty name or a name not beginning with an alphabetic character will result in a beep.  Similar checks are done for Remove and Save.
  195.  
  196. • Remove:  When a name is supplied in the Edit field, you can Remove any methods that have source, including poly and squiral -- I'd recommend not removing poly if you plan to use squiral or squiral2.  This removes both the source and compiled versions.  Since the button is "out of the way", I currently do not provide a warning after you tap it.  However, if you do an Edit first, the source is still in the source area in case you change your mind and want to Save it again as the same name (or as a different name, which is the way to do "Rename").  Note: when you remove all methods (including poly and squiral), Newt will remove the preference entry when you quit.  You can apparently remove "evalField", but not really.
  197.  
  198. • Save: Once you have begun to edit the method, the "Save" and "Revert" buttons appear (and the "Edit" and "Remove" buttons and closebox disappear).  When you tap on "Save", Newt will compile the method and save your source if successful.  Note that it uses the name currently in the "Edit" field, so one way to copy a method is to "Edit" it, then change the name and make any change to the method, and then "Save".
  199.  
  200. [note: when you Save, you may get a beep for an invalid method name.  If Newton is unsuccessful at compiling your code, you'll get an error box (see earlier description under "Eval" and later under "Errors").  When successful, the source is saved in the Newt preferences entry (in the system soup).  Each time Newt is started, it compiles all of the method sources that it finds there so that you can use them immediately.]
  201.  
  202. • Revert: If you wish to discard any edits you have made since the last Save, just tap "Revert" (warning: there is no warning/confirmation).  The last-saved source is then displayed for the method named in the "Edit" field (usually the current method, but it could be the name of the next method you want to view).
  203.  
  204. • <close box>: This disappears when you begin to edit source.  After a "Save" or "Revert", it reappears thus allowing you to exit the Define screen.
  205.  
  206. • <source area>: This is just a "paragraph view" for writing and typing.  Double tap to get standard keyboard.  A future version may include programmable buttons with code snippets (or maybe someone will just write a generic, smart, multiple clipboard).
  207.  
  208. =====
  209.  
  210. Errors
  211. -----
  212.  
  213. In the unlikely event that a system box pops up with a cryptic error code, check the following partial list of common error codes, and see if there might be something missing or extra in one of your values or expressions. 
  214. Code       Description
  215. -8007:    syntax error (from compiler)
  216. -48404:  expected a number
  217. -48402:  expected an integer
  218. -48803:  wrong number of arguments
  219. -48807:  undefined variable
  220. -48809:  undefined method
  221. 1627052: divide by zero
  222.  
  223. If you have a Macintosh, you might also want to get the "LowDown" DA, available from one of the usual Newton libraries/ftp archives/bboards, that provides a more complete list of errors from the NTK docs.
  224.  
  225. Things to try: check your syntax against those in examples, check spelling for method and variable names, check number of arguments, check type of arguments (e.g., float vs. integer).  If you think it's really a problem with Newt, send me mail describing what you had entered, and I'll try to respond within a day or two.
  226.  
  227. =====
  228.  
  229. Possible Next Steps
  230. -----
  231. There are many features/fixes that would be nice to have.  However, there are design tradeoffs, esp. given the MessagePad's constraints.  So, help me figure out:
  232.   • where does it go on the screen?
  233.   • is it worth the extra memory space?
  234.   • can it take advantage of existing Newton mechanisms or metaphors?
  235.  
  236. Some possibilities:
  237. • online help (this readme file ~20K)
  238. • tuning recognizer for code (e.g., no prompting for dictionary additions?)
  239. • more gestural input
  240. • save code in another soup (e.g., Notes to take advantage of printing, beaming, etc.)
  241. • misc. interface cleanup (e.g., confirm Revert and Remove ?)
  242. • multiple Newts (maybe when there's a bigger color screen?)
  243. • misc. drawing features (e.g., pen mode (xor, etc.))
  244. • more examples, documentation,...
  245. • streamline code editing (macro buttons or customized keyboard)
  246. • a print area (and subset of string/list Logo equivalent commands)
  247.  
  248. In addition to suggestions and opinions, pointers to documentation and examples would be greatly appreciated.
  249.  
  250. =====
  251.  
  252. History/Credits
  253.  
  254. I first implemented a screen turtle on an IMLAC display computer, accessed from BBN Logo on a DEC PDP-10 circa 1972 (wow, that makes me feel ancient).  Subsequently, I implemented other versions in Lisp, and used others in Smalltalk and ObjectLogo.
  255.  
  256. The two tiny NTK examples, Dot2Dot and InspectorGadget, with a little creative juxtaposition, started me down this path. 
  257.  
  258. Apple deserves credit for creating an exciting product (Newton) and powerful development environment (NTK) and I look forward to better documentation and even more examples.  Newton and Newton ToolKit are trademarks of Apple Computer.
  259.  
  260. Finally, my family deserves credit for giving me the evening and weekend time to explore this; Ellie helped with testing.
  261.